{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From https://github.com/gee-community/ee-jupyter-contrib/blob/master/examples/export/export-image-gdrive.ipynb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "\n",
    "from IPython.display import Image\n",
    "\n",
    "import ee\n",
    "ee.Initialize()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# use ALOS DEM\n",
    "dem = ee.Image(\"JAXA/ALOS/AW3D30_V1_1\").select('MED')\n",
    "\n",
    "# define export region\n",
    "region = ee.Geometry.LineString([[93.116, 28.709], [93.148, 28.673]]).bounds()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/wAALCAEAAOQBAREA/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEBAAA/APyhk1Jwflf9f/r0Jqcn8TH8/wD69SJrTrx5j9fX/wCvV201txgtIfz/APr1o23iDaBmX/x7/wCvV2PxEAozMen97/69WbPxACu15j/31/8AXq7F4iGB+8J/4F/9erkXiJVH+tH4t/8AXqeHxGGPzyn8G/8Ar1oQeJYwvyynPs3/AN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nvXR6PpLKV8scZH9Peu98J6KJ7cN/EG4/Ie9dx4ds5rd0jccYA/lXUR6dGYPMUduT+FYusW5DMB2PH6Vzd8h3fNWBrLpBwep6fpXNXdsJmLMPwrPns4wQCv61Wk0yJzkH/AD+dLHpa5wo/z+dX7DQQ8gJX9fr710NjpmxgvTH+fWt64V4bXj8T+Ncf4gmcOc/3f6GuR1m4JZsN2Pb61zGrMSGJPr/WsC+RnJyetZlxaHBIHesjVH8tSmP881galKGOw/561j38IKkN0P8A9esi7tI8HA/Wsu7gEedormvEsyxI3y9D6+4rir+6knY4/wA9KqpACQG/GtFICFAFfpfpenFWUr7f0rp9FsGLKNvp3+ldx4W094tjIMfMCf0rvdB003BXjOcf0966WPSCloQVxx6+31rnNf0+NXfLY59PpXGa40Nun7tsn6H2rjNWLyTFm5/yKyLhiCcVWaMytjpU0GnqOSM1dtdKZ3Hy/hn/AOvXRaT4fOA7Jx9fr71qroiQney/r/8AXrO1678tDGh49MfSuH8QXAMhO7sMcexrldUZnkIJx/k1kXto0iEgZrLfSWkY54H+feqt/p0MURUHnHT865DxDbKpbYMnJ/rXK6rKYc8c/wD66xLu7Yk5Pesu9vyoPy/rWXqF4skfLcfT61zWvPFOjRbuM88e4rlrrTgjZBplraqZPmrZgtI2iBBr/9k=\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# preview image to be exported\n",
    "image = dem.visualize(**{ 'min': 3800, 'max': 5260 })\n",
    "\n",
    "# generate url to image thumbnail\n",
    "url = image.getThumbUrl({'region': region.getInfo(), 'dimensions': 256})\n",
    "\n",
    "# display image\n",
    "Image(url=url, embed=True, format='png')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "XF5PUZUHXRSVV56TEY7WUEKC\n"
     ]
    }
   ],
   "source": [
    "# schedule a new export image task, here we will export to Google Drive\n",
    "file_name = 'dem'\n",
    "export_region = region.getInfo()['coordinates'] # BUG: it should just accept region as-is\n",
    "task = ee.batch.Export.image.toDrive(dem, description=file_name, fileNamePrefix=file_name, region=export_region, scale=30)\n",
    "task.start()\n",
    "\n",
    "# remember task id and use it to check tasks status later\n",
    "task_id = task.id\n",
    "print(task_id)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "__init__() missing 2 required positional arguments: 'task_type' and 'state'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-5-0b365e701786>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;31m# create a new task using id\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mtask\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mee\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbatch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTask\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtask_id\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: __init__() missing 2 required positional arguments: 'task_type' and 'state'"
     ]
    }
   ],
   "source": [
    "# create a new task using id\n",
    "task = ee.batch.Task(task_id)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[0;31mInit signature:\u001b[0m \u001b[0mee\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbatch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTask\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtask_id\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtask_type\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstate\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mDocstring:\u001b[0m      A batch task that can be run on the EE batch processing system.\n",
       "\u001b[0;31mInit docstring:\u001b[0m\n",
       "Creates a Task with the given ID and configuration.\n",
       "\n",
       "The constructor is not for public use. Instances can be obtained by:\n",
       "- Calling the static method Task.list().\n",
       "- Calling any of the methods on the Export static class.\n",
       "- Unpickling a previously pickled Task object.\n",
       "\n",
       "If you're looking for a task's status but don't need a full task object,\n",
       "ee.data.getTaskStatus() may be appropriate.\n",
       "\n",
       "Args:\n",
       "  task_id: The task ID, originally obtained through ee.data.newTaskId().\n",
       "    May be None if the ID is not yet known.\n",
       "  task_type: The type of the task; one of the values in Task.Type.\n",
       "  state: The state of the task; one of the values entries in Task.State.\n",
       "  config: The task configuration dictionary. Only necessary if start()\n",
       "      will be called. Fields shared by all tasks are:\n",
       "      - description: The name of the task, a freeform string.\n",
       "      - sourceURL: An optional URL for the script that generated the task.\n",
       "      Specific task types have other custom config fields.\n",
       "  name: The name of the operation.  Only relevant when using the cloud api.\n",
       "\u001b[0;31mFile:\u001b[0m           ~/opt/anaconda3/envs/earthengine/lib/python3.7/site-packages/ee/batch.py\n",
       "\u001b[0;31mType:\u001b[0m           type\n",
       "\u001b[0;31mSubclasses:\u001b[0m     \n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ee.batch.Task?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 'XF5PUZUHXRSVV56TEY7WUEKC',\n",
       " 'state': 'COMPLETED',\n",
       " 'creation_timestamp_ms': 1571890369811,\n",
       " 'update_timestamp_ms': 1571890393524,\n",
       " 'description': 'dem',\n",
       " 'task_type': 'EXPORT_IMAGE',\n",
       " 'output_url': ['https://drive.google.com/'],\n",
       " 'start_timestamp_ms': 1571890383680}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "task.status()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "<Task EXPORT_IMAGE: dem (COMPLETED)>\n"
     ]
    }
   ],
   "source": [
    "# query current user tasks\n",
    "tasks = ee.batch.Task.list()\n",
    "\n",
    "print(len(tasks))\n",
    "print(tasks[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
